package top.zhangjianyong.tools.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.zhangjianyong.tools.annotation.Mark;
import top.zhangjianyong.tools.parm.AreaListParam;
import top.zhangjianyong.tools.service.api.AreaService;
import top.zhangjianyong.tools.user.VerifyUser;
import top.zhangjianyong.tools.utils.ApiResponse;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zhangjianyong
 * @since 2024/9/29 上午10:55
 */
@VerifyUser(login = false)
@RestController
@RequestMapping("/area")
public class AreaController {

    @Autowired
    private AreaService areaService;

    @Mark
    @PostMapping("/list")
    public ApiResponse list(@RequestBody AreaListParam param) {
        return areaService.list(param);
    }

    @GetMapping("/random")
    public ApiResponse ramdom(@RequestParam("code") String areaCode, HttpServletResponse response) throws IOException {
        return areaService.ramdom(areaCode,response);
    }
}
